/**
 * 提示框
 * 
 * @author luo
 * @email luo4521@online.net.tw
 * 2010-1-28 10:34
 */
package com.addcn.texas.view.components
{
	import flash.display.*;
	import flash.events.*;
	import flash.text.TextField;
	
	public class alert extends winBase
	{		
		public static const OK_EVENT : String = 'OKEvent';
		private var _msg : String;
		private var _parent : Object;
		
		function alert (r_parent : Object) : void {	
			this._parent = r_parent;
			this.alpha = 0.9;
			init();			
		}		
		
		private function init() : void {			
			this.drag(this['bg']);					
			this["ok_btn"].addEventListener(MouseEvent.CLICK, ok_btnClickHandler);		
		}
		
		public function set msg(r_msg : String) : void {
			this._msg = r_msg;
			this["notice"].text = this._msg;
		}
		
		public function show() {			
			if (this._parent != null) {		
				this._parent.addChildAt(this,(this._parent.numChildren-1));	
				this.x = (this._parent.stage.stageWidth -this.width)/ 2;
				this.y = (this._parent.stage.stageHeight - this.height) / 2;					
			}
		}
		
		public override function remove() :void {
			super.remove();
			if(this._parent != null){
				this._parent.removeChild(this);
			}
		}
		
		private function ok_btnClickHandler(evt : Event) : void {
			this.remove();
			this["ok_btn"].removeEventListener(MouseEvent.CLICK, ok_btnClickHandler);
			var event : Event = new Event(alert.OK_EVENT);
			this.dispatchEvent(event);
		}
		
	}
	
}
